<!DOCTYPE html>
<html>
<head>
	<title>{$pageData.title}</title>
	<script type="text/javascript" src="__STATIC__/common/js/jquery.min.js"></script>
	<link rel="stylesheet" href="__STATIC__/manage/css/common.css" type="text/css">
	<link rel="stylesheet" href="__STATIC__/manage/css/member.css" type="text/css">
</head>
<body>
<div id="box-header"></div>
<div id="box-main">
	<div id="box-side">
		<div class="wrapper">{include file="inc/menu" /}</div>
	</div>
	<div id="box-content">
		<div class="wrapper">
			<form name="postForm">
				<table id="dataTable" class="dataTable" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td>用户编号</td>
						<td><input type="text" name="mid" value=""></td>
					</tr>
					<tr>
						<td>用户姓名</td>
						<td><input type="text" name="mname" value=""></td>
					</tr>
					<tr>
						<td>会员类型</td>
						<td>
							<select name="type" >
								<option value="2">实单</option>
								<option value="1">空单</option>
							</select>
						</td>
					</tr>
					<tr>
						<td>代理中心</td>
						<td><input type="text" name="agent_id" value=""></td>
					</tr>
					<tr>
						<td>邀请人</td>
						<td><input type="text" name="inviter_id" value=""></td>
					</tr>
					<tr>
						<td>安置人</td>
						<td><input type="text" name="seter_id" value=""></td>
					</tr>
					<tr>
						<td>所在大区</td>
						<td><select name="area" id=""><option value="0">A区</option><option value="1">B区</option></select></td>
					</tr>
					<tr>
						<td>会员等级</td>
						<td><select name="level_id"></select></td>
					</tr>
					<tr>
						<td>用户密码</td>
						<td><input type="text" name="password" value=""></td>
					</tr>
					<tr>
						<td></td>
						<td><input type="button" value="添加会员" onclick="addMember()"></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<div class="clearfix"></div>
</div>

<script type="text/javascript">
$(function(){
	getLevels();
})

function getLevels(){
	$.ajax({
		'type':'post',
		'dataType':'json',
		'data':'',
		'url':"{:url('level.api/levels')}",
		'success':function(data){
			var levelHtml = '';
			$.each(data,function(index,value){
				levelHtml += '<option value="'+value.id+'">'+value.level_name+'</option>';
			});
			$("select[name=level_id]").html(levelHtml);
		}
	});
}
function addMember(){
	var theData = $("form[name=postForm]").serialize();
	$.ajax({
		'type':'post',
		'dataType':'json',
		'data':theData,
		'url':"{:url('member.handle/add')}",
		'success':function(data){
			alert(data.msg);
		}
	});
}
</script>
</body>
</html>